package com.example.mobile203zlw20216061300506;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView textView;
    private Button buttonIE;
    private EditText editTextUri;
    private Button buttonPhone;
    private Button buttonEM;
    private Button buttonPc;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        textView = (TextView) findViewById(R.id.textView);
        buttonIE = (Button) findViewById(R.id.button_IE);
        editTextUri = (EditText) findViewById(R.id.editText_uri);
        buttonPhone = (Button) findViewById(R.id.button_phone);
        buttonEM = (Button) findViewById(R.id.button_EM);
        buttonPc = (Button) findViewById(R.id.button_pc);
    }
    public void IE(View view) {
        textView = (TextView) findViewById(R.id.textView);
        buttonIE = (Button) findViewById(R.id.button_IE);
        editTextUri = (EditText) findViewById(R.id.editText_uri);
        buttonPhone = (Button) findViewById(R.id.button_phone);
        buttonEM = (Button) findViewById(R.id.button_EM);
        buttonPc = (Button) findViewById(R.id.button_pc);
        String string=editTextUri.getText().toString().trim();
        Uri uri=Uri.parse(string);
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        startActivity(intent);
    }
    public void bt_2bohao(View view) {
        textView = (TextView) findViewById(R.id.textView);
        buttonIE = (Button) findViewById(R.id.button_IE);
        editTextUri = (EditText) findViewById(R.id.editText_uri);
        buttonPhone = (Button) findViewById(R.id.button_phone);
        buttonEM = (Button) findViewById(R.id.button_EM);
        buttonPc = (Button) findViewById(R.id.button_pc);
        String string=editTextUri.getText().toString().trim();
        Uri uri=Uri.parse("tel:"+string);
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        startActivity(intent);
    }
    public void pc(View view) {
        textView = (TextView) findViewById(R.id.textView);
        buttonIE = (Button) findViewById(R.id.button_IE);
        editTextUri = (EditText) findViewById(R.id.editText_uri);
        buttonPhone = (Button) findViewById(R.id.button_phone);
        buttonEM = (Button) findViewById(R.id.button_EM);
        buttonPc = (Button) findViewById(R.id.button_pc);
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivity(intent);
    }
    public void EM(View view) {
        textView = (TextView) findViewById(R.id.textView);
        buttonIE = (Button) findViewById(R.id.button_IE);
        editTextUri = (EditText) findViewById(R.id.editText_uri);
        buttonPhone = (Button) findViewById(R.id.button_phone);
        buttonEM = (Button) findViewById(R.id.button_EM);
        buttonPc = (Button) findViewById(R.id.button_pc);
        String string=editTextUri.getText().toString().trim();
        Uri uri=Uri.parse("smsto:"+string);
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        intent.putExtra("面对疾风吧","0杠21了");
        startActivity(intent);
    }
}